package top.lyc829.zzl_android.logic.network;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import top.lyc829.zzl_android.logic.util.Utils;

/**
 * @Author lyc
 * @create 2021-03-12 19:35
 */
public class TokenInterceptor implements Interceptor {
    @NotNull
    @Override
    public Response intercept(@NotNull Chain chain) throws IOException {
        Request request = chain.request();
        Response response = chain.proceed(request);
        String token = response.header("token", "");
        Utils.Sout(token);
        if (!Utils.isStringEmpty(token)) {
            Utils.insertToSp("token", token);
        }

        Utils.SoutInfo(response.toString());

        return response;
    }
}
